#include "menu.h"
#include "easy_ui.h"
#include "page.h"
#include "element.h"
#include "control.h"

static EasyUIPage_t pageCtrlSet;
static EasyUIItem_t titlepageCtrlSet, jumpBlock, jumpRoundIn, jumpRoundOut, ElemRead, ELemWrite, BlockDist, CarVelo, LaserSW, CcCopy, QuitSW;

static EasyUIPage_t pageBlockSet;
static EasyUIItem_t titleBlockSet, BlockGSA, BlockGSS, BlockGSE, BlockTLA1, BlockTLS1, BlockTLE1,
    BlockTRA1, BlockTRS1, BlockTRE1, BlockTRA2, BlockTRS2, BlockTRE2, BlockTLA2, BlockTLS2, BlockTLE2;

static EasyUIPage_t pageRoundInSet;
static EasyUIItem_t titleRoundInSet, RoundInGSA, RoundInGSS, RoundInGSE, RoundInTRA, RoundInTRS, RoundInTRE;

static EasyUIPage_t pageRoundOutSet;
static EasyUIItem_t titleRoundOutSet, RoundOutGSA, RoundOutGSS, RoundOutGSE;

// EasyUIItem_t itemSave, itemReset;
// EasyUIItem_t titleMain, itemChkBox, itemRadButton, itemSw, itemVal, itemTim4,itemVelocity;
// EasyUIItem_t titleCheckbox, itemCh1, itemCh2, itemCh3, itemCh4;
// EasyUIItem_t titleRadButton, itemButton1, itemButton2, itemButton3, itemButton4;
// EasyUIItem_t titleSw, itemCtrl, itemSw2, itemSw3;
// EasyUIItem_t titleVal, itemFloat, itemInt, itemUint;

// bool ch1 = TRUE, ch2 = TRUE, ch3 = FALSE, ch4 = TRUE;
// bool rb1 = FALSE, rb2 = TRUE, rb3 = FALSE, rb4 = FALSE;
// bool sw2 = FALSE, sw3 = TRUE;
// fp32 testFloat = 0.68, testInt = 5, testUint = 34;

void Menu_Init()
{
    EasyUIAddPage(&pageCtrlSet, PAGE_LIST);
    EasyUIAddPage(&pageBlockSet, PAGE_LIST);
    EasyUIAddPage(&pageRoundInSet, PAGE_LIST);
    EasyUIAddPage(&pageRoundOutSet, PAGE_LIST);

    EasyUIAddItem(&pageCtrlSet, &titlepageCtrlSet, "[CtrlSettings]", ITEM_PAGE_DESCRIPTION);
    EasyUIAddItem(&pageCtrlSet, &BlockDist, "BlockDist", ITEM_CHANGE_VALUE, &Elem.BlockDist, EasyUIEventChangeUint);
    EasyUIAddItem(&pageCtrlSet, &CcCopy, "Cc*1000", ITEM_CHANGE_VALUE, &Ctrl.CcCopy, EasyUIEventChangeUint);
    EasyUIAddItem(&pageCtrlSet, &CarVelo, "CarVelo", ITEM_CHANGE_VALUE, &CarVelocity, EasyUIEventChangeInt);
    EasyUIAddItem(&pageCtrlSet, &LaserSW, "LaserSW", ITEM_SWITCH, &Elem.LaserSW);
    EasyUIAddItem(&pageCtrlSet, &jumpBlock, "BlockSet", ITEM_JUMP_PAGE, pageBlockSet.id);
    EasyUIAddItem(&pageCtrlSet, &jumpRoundIn, "RoundInSet", ITEM_JUMP_PAGE, pageRoundInSet.id);
    EasyUIAddItem(&pageCtrlSet, &jumpRoundOut, "RoundOutSet", ITEM_JUMP_PAGE, pageRoundOutSet.id);
    EasyUIAddItem(&pageCtrlSet, &ElemRead, "ReadElem", ITEM_SWITCH, &Elem.FlashRead);
    EasyUIAddItem(&pageCtrlSet, &QuitSW, "Quit?", ITEM_SWITCH, &Page.ElemSet);
    EasyUIAddItem(&pageCtrlSet, &ELemWrite, "WriteElem", ITEM_SWITCH, &Elem.FlashWrite);

    EasyUIAddItem(&pageBlockSet, &titleBlockSet, "[BlockSet]", ITEM_PAGE_DESCRIPTION);
    EasyUIAddItem(&pageBlockSet, &BlockGSA, "GSAngle", ITEM_CHANGE_VALUE, &Response[Block][0].Angle, EasyUIEventChangeInt);
    EasyUIAddItem(&pageBlockSet, &BlockGSS, "GSSpeed", ITEM_CHANGE_VALUE, &Response[Block][0].Speed, EasyUIEventChangeInt);
    EasyUIAddItem(&pageBlockSet, &BlockGSE, "GSEnco", ITEM_CHANGE_VALUE, &Response[Block][0].Displace, EasyUIEventChangeInt);
    EasyUIAddItem(&pageBlockSet, &BlockTLA1, "TL1Angle", ITEM_CHANGE_VALUE, &Response[Block][1].Angle, EasyUIEventChangeInt);
    EasyUIAddItem(&pageBlockSet, &BlockTLS1, "TL1Speed", ITEM_CHANGE_VALUE, &Response[Block][1].Speed, EasyUIEventChangeInt);
    EasyUIAddItem(&pageBlockSet, &BlockTLE1, "TL1Enco", ITEM_CHANGE_VALUE, &Response[Block][1].Displace, EasyUIEventChangeInt);
    EasyUIAddItem(&pageBlockSet, &BlockTRA1, "TR1Angle", ITEM_CHANGE_VALUE, &Response[Block][2].Angle, EasyUIEventChangeInt);
    EasyUIAddItem(&pageBlockSet, &BlockTRS1, "TR1Speed", ITEM_CHANGE_VALUE, &Response[Block][2].Speed, EasyUIEventChangeInt);
    EasyUIAddItem(&pageBlockSet, &BlockTRE1, "TR1Enco", ITEM_CHANGE_VALUE, &Response[Block][2].Displace, EasyUIEventChangeInt);
    EasyUIAddItem(&pageBlockSet, &BlockTRA2, "TR2Angle", ITEM_CHANGE_VALUE, &Response[Block][3].Angle, EasyUIEventChangeInt);
    EasyUIAddItem(&pageBlockSet, &BlockTRS2, "TR2Speed", ITEM_CHANGE_VALUE, &Response[Block][3].Speed, EasyUIEventChangeInt);
    EasyUIAddItem(&pageBlockSet, &BlockTRE2, "TR2Enco", ITEM_CHANGE_VALUE, &Response[Block][3].Displace, EasyUIEventChangeInt);
    EasyUIAddItem(&pageBlockSet, &BlockTLA2, "TL2Angle", ITEM_CHANGE_VALUE, &Response[Block][4].Angle, EasyUIEventChangeInt);
    EasyUIAddItem(&pageBlockSet, &BlockTLS2, "TL2Speed", ITEM_CHANGE_VALUE, &Response[Block][4].Speed, EasyUIEventChangeInt);
    EasyUIAddItem(&pageBlockSet, &BlockTLE2, "TL2Enco", ITEM_CHANGE_VALUE, &Response[Block][4].Displace, EasyUIEventChangeInt);

    EasyUIAddItem(&pageRoundInSet, &titleRoundInSet, "[RoundInSet]", ITEM_PAGE_DESCRIPTION);
    EasyUIAddItem(&pageRoundInSet, &RoundInGSA, "GSAngle", ITEM_CHANGE_VALUE, &Response[Round_In][0].Angle, EasyUIEventChangeInt);
    EasyUIAddItem(&pageRoundInSet, &RoundInGSS, "GSSpeed", ITEM_CHANGE_VALUE, &Response[Round_In][0].Speed, EasyUIEventChangeInt);
    EasyUIAddItem(&pageRoundInSet, &RoundInGSE, "GSEnco", ITEM_CHANGE_VALUE, &Response[Round_In][0].Displace, EasyUIEventChangeInt);
    EasyUIAddItem(&pageRoundInSet, &RoundInTRA, "TRAngle", ITEM_CHANGE_VALUE, &Response[Round_In][1].Angle, EasyUIEventChangeInt);
    EasyUIAddItem(&pageRoundInSet, &RoundInTRS, "TRSpeed", ITEM_CHANGE_VALUE, &Response[Round_In][1].Speed, EasyUIEventChangeInt);
    EasyUIAddItem(&pageRoundInSet, &RoundInTRE, "TREnco", ITEM_CHANGE_VALUE, &Response[Round_In][1].Displace, EasyUIEventChangeInt);

    EasyUIAddItem(&pageRoundOutSet, &titleRoundOutSet, "[RoundOutSet]", ITEM_PAGE_DESCRIPTION);
    EasyUIAddItem(&pageRoundOutSet, &RoundOutGSA, "GSAngle", ITEM_CHANGE_VALUE, &Response[Round_Out][0].Angle, EasyUIEventChangeInt);
    EasyUIAddItem(&pageRoundOutSet, &RoundOutGSS, "GSSpeed", ITEM_CHANGE_VALUE, &Response[Round_Out][0].Speed, EasyUIEventChangeInt);
    EasyUIAddItem(&pageRoundOutSet, &RoundOutGSE, "GSEnco", ITEM_CHANGE_VALUE, &Response[Round_Out][0].Displace, EasyUIEventChangeInt);

    // EasyUIAddItem(&pageMain, &titleMain, "[Main]", ITEM_PAGE_DESCRIPTION);
    // EasyUIAddItem(&pageMain, &itemCtrl, "Car start", ITEM_SWITCH, &Ctrl.CarStart);
    // EasyUIAddItem(&pageMain, &itemChkBox, "Test checkbox", ITEM_JUMP_PAGE, pageCheckbox.id);
    // EasyUIAddItem(&pageMain, &itemRadButton, "Test radio button", ITEM_JUMP_PAGE, pageRadButton.id);
    // EasyUIAddItem(&pageMain, &itemSw, "Test switches", ITEM_JUMP_PAGE, pageSwitch.id);
    // EasyUIAddItem(&pageMain, &itemVal, "Test change value", ITEM_JUMP_PAGE, pageChgVal.id);
    // EasyUIAddItem(&pageMain, &itemSave, "Save settings", ITEM_MESSAGE, "Saving...", EasyUIEventSaveSettings);
    // EasyUIAddItem(&pageMain, &itemReset, "Reset settings", ITEM_MESSAGE, "Resetting...", EasyUIEventResetSettings);

    // EasyUIAddItem(&pageCheckbox, &titleCheckbox, "[Multiple selection]", ITEM_PAGE_DESCRIPTION);
    // EasyUIAddItem(&pageCheckbox, &itemCh1, "Checkbox 1", ITEM_CHECKBOX, &ch1);
    // EasyUIAddItem(&pageCheckbox, &itemCh2, "Checkbox 2", ITEM_CHECKBOX, &ch2);
    // EasyUIAddItem(&pageCheckbox, &itemCh3, "Checkbox 3", ITEM_CHECKBOX, &ch3);
    // EasyUIAddItem(&pageCheckbox, &itemCh4, "Checkbox 4", ITEM_CHECKBOX, &ch4);

    // EasyUIAddItem(&pageRadButton, &titleRadButton, "[Single selection]", ITEM_PAGE_DESCRIPTION);
    // EasyUIAddItem(&pageRadButton, &itemButton1, "Radio button 1", ITEM_RADIO_BUTTON, &rb1);
    // EasyUIAddItem(&pageRadButton, &itemButton2, "Radio button 2", ITEM_RADIO_BUTTON, &rb2);
    // EasyUIAddItem(&pageRadButton, &itemButton3, "Radio button 3", ITEM_RADIO_BUTTON, &rb3);
    // EasyUIAddItem(&pageRadButton, &itemButton4, "Radio button 4", ITEM_RADIO_BUTTON, &rb4);

    // EasyUIAddItem(&pageSwitch, &titleSw, "[Switch]", ITEM_PAGE_DESCRIPTION);
    // //    EasyUIAddItem(&pageSwitch, &itemColor, "Reversed color", ITEM_SWITCH, &reversedColor);
    // EasyUIAddItem(&pageSwitch, &itemSw2, "Switch 2", ITEM_SWITCH, &sw2);
    // EasyUIAddItem(&pageSwitch, &itemSw3, "Switch 3", ITEM_SWITCH, &sw3);

    // EasyUIAddItem(&pageChgVal, &titleVal, "[Change value]", ITEM_PAGE_DESCRIPTION);
    // EasyUIAddItem(&pageChgVal, &itemFloat, "Test float", ITEM_CHANGE_VALUE, &testFloat, EasyUIEventChangeFloat);
    // EasyUIAddItem(&pageChgVal, &itemInt, "Test int", ITEM_CHANGE_VALUE, &testInt, EasyUIEventChangeInt);
    // EasyUIAddItem(&pageChgVal, &itemUint, "Test uint", ITEM_CHANGE_VALUE, &testUint, EasyUIEventChangeUint);
}
